package org.holynite.fieldmanage.managed.support

import org.holynite.fieldmanage.ejbs.AuthorizationManagement
import org.holynite.fieldmanage.entities.AdministratorRole

import javax.annotation.PostConstruct
import javax.ejb.EJB
import javax.faces.bean.ManagedBean
import javax.faces.bean.SessionScoped

/**
 * Created by midnite on 15/1/31.
 */
@ManagedBean
@SessionScoped
class RolesBean implements Serializable {
    List<AdministratorRole> roles

    @EJB(beanName = "adminRoleControl")
    AuthorizationManagement roleService

    RolesBean() {
        roles = []
    }

    @PostConstruct
    void initiate() {
        roles = roleService.listAllRoles()
    }

    AdministratorRole selectRole(String roleId) {
        roles.find { it.svrid.equals(roleId) }
    }
}
